package cn.psvmc.cxzapi.controller.customer;

import cn.psvmc.cxzapi.response.Result;
import cn.psvmc.cxzapi.response.ResultGenerator;
import cn.psvmc.cxzapi.service.customer.FileUploadService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author YWX
 * @Classname FileUploadController
 * @Description 文件上传
 * @Date 2024/9/8 18:01
 **/
@RestController
@RequestMapping("/mpapi/file_upload")
public class FileUploadController {
    @Resource
    private FileUploadService fileUploadService;

    /**
     * @Description 上传文件到oss
     * @Date 2024/9/8 21:26
     * @Author YWX
     * @Param [file, map]
     * @Return cn.psvmc.cxzapi.response.Result
     **/
    @PostMapping("/upload_oss")
    public Result uploadOss(@RequestParam("file") MultipartFile file, @RequestParam Map<String, String> map) {
        if (file == null) {
            return ResultGenerator.genFailResult("文件不能为空!");
        }
        return fileUploadService.uploadOss(file, map);
    }
}
